package com.heaven1949.tmall.gateway.controller;

import com.google.common.collect.Lists;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.List;

@Data
public class RouteSaveRequest {
	
	/**
	 * 路由配置ID
	 */
	private Long id;
	/**
	 * 路由ID
	 */
	private String routeId;
	
	@NotBlank(message = "路由地址不能为空")
	private String path;
	/**
	 * 服务ID
	 */
	@NotBlank(message = "服务ID不能为空")
	private String serviceId;
	
	@NotBlank(message = "服务名称不能为空")
	private String serviceName;
	/**
	 * 转发地址
	 */
	private String uri;
	
	private Integer status;
	/**
     * 是否加入SSO
     */
    private Integer isJoinSso;
    /**
     * 认证校验URL
     */
    private String ssoAuthenticateUrl;
    /**
     * 认证排除URL
     */
    private String ssoAuthenticateExcludeUrl;
	/**
	 * 断言
	 */
//	@NotEmpty(message = "断言配置信息不能为空")
	private List<RoutePredicateSaveRequest> predicates;
	/**
	 * 过滤器
	 */
	private List<RouteFilterSaveRequest> filters;
	/**
	 * 顺序号
	 */
	private Integer orderNo;
	private String serviceDescription;
	
	public void addPredicate(RoutePredicateSaveRequest predicate) {
		if(this.predicates==null)this.predicates=Lists.newArrayList();
		this.predicates.add(predicate);
	}
	
	public void addFilter(RouteFilterSaveRequest filter) {
		if(this.filters==null)this.filters=Lists.newArrayList();
		this.filters.add(filter);
	}

}
